<template>
  <p>{{ age }}</p>
  <button @click="age++">click</button>
</template>

<script>
import { watch, ref } from 'vue'
export default {
  name: 'App',
  setup() {
    const age = ref(18)
    // 监听 ref 数据 age，会触发后面的回调，不需要 .value
    watch(age, (newValue, oldValue) => {
      console.log(newValue, oldValue)
    })

    return { age }
  },
}
</script>
